package com.yanqu.road.entity.zhaoshang;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.player.UserBaseInfo;

import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 城郊-招商-项目集
 */
public class ZsProject extends DataObject {

    private long projectId;       //项目id

    private int  templateId;      //项目配置id

    private long openUserId;      //立项玩家

    private int openTime;        //立项时间(秒)

    private long serverId;        //所属区服

    private int duration;         //持续时长（分钟)

    private int titleAddition;    //身份加成（千分比）

    private int stateVal;         //状态（0：进行中；1：结束)

    private int finishType;       //收官类型（0：正常；1：区服变化)

    private boolean sendReward;         //是否发奖励(0:否；1:是)

    private UserBaseInfo openUser;      //立项玩家详情

    private Map<Integer, ZsProjectSeat> seatMap = new ConcurrentHashMap<>();        //占位信息

    private Map<Integer, UserBaseInfo> seatUserMap = new ConcurrentHashMap<>();   //占位玩家信息

    private int addition;             //称号加成

    private long decorationOverTime;   //称号过期时间（秒）

    private String baseReward;       //基础收益

    private long expectProfit;        //预计收益，不存储，仅用于排序

    private ZsProjectAdditionData additionData;

    public long getProjectId() {
        return projectId;
    }

    public void setProjectId(long projectId) {
        if(this.projectId != projectId) {
            this.projectId = projectId;
            setUpdateOption();
        }
    }

    public int getTemplateId() {
        return templateId;
    }

    public void setTemplateId(int templateId) {
        if(this.templateId != templateId) {
            this.templateId = templateId;
            setUpdateOption();
        }
    }

    public long getOpenUserId() {
        return openUserId;
    }

    public void setOpenUserId(long openUserId) {
        if(this.openUserId != openUserId) {
            this.openUserId = openUserId;
            setUpdateOption();
        }
    }

    public int getOpenTime() {
        return openTime;
    }

    public void setOpenTime(int openTime) {
        if(this.openTime != openTime) {
            this.openTime = openTime;
            setUpdateOption();
        }
    }

    public long getServerId() {
        return serverId;
    }

    public void setServerId(long serverId) {
        if(this.serverId != serverId) {
            this.serverId = serverId;
            setUpdateOption();
        }
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        if(this.duration != duration) {
            this.duration = duration;
            setUpdateOption();
        }
    }

    public int getTitleAddition() {
        return titleAddition;
    }

    public void setTitleAddition(int titleAddition) {
        if(this.titleAddition != titleAddition) {
            this.titleAddition = titleAddition;
            setUpdateOption();
        }
    }

    public int getStateVal() {
        return stateVal;
    }

    public void setStateVal(int stateVal) {
        if(this.stateVal != stateVal) {
            this.stateVal = stateVal;
            setUpdateOption();
        }
    }

    public int getFinishType() {
        return finishType;
    }

    public void setFinishType(int finishType) {
        if(this.finishType != finishType) {
            this.finishType = finishType;
            setUpdateOption();
        }
    }

    public boolean isSendReward() {
        return sendReward;
    }

    public void setSendReward(boolean sendReward) {
        if(this.sendReward != sendReward) {
            this.sendReward = sendReward;
            setUpdateOption();
        }
    }

    public UserBaseInfo getOpenUser() {
        return openUser;
    }

    public void setOpenUser(UserBaseInfo openUser) {
        this.openUser = openUser;
        setUpdateOption();
    }

    public String getOpenUserJsonStr(){
        if(null == openUser){
            return "";
        }else {
            return JSON.toJSONString(openUser);
        }
    }

    public Map<Integer, ZsProjectSeat> getSeatMap() {
        return seatMap;
    }

    public void setSeatMap(Map<Integer, ZsProjectSeat> seatMap) {
        this.seatMap = seatMap;
        setUpdateOption();
    }

    public void setSeat(int key, ZsProjectSeat seat){
        this.seatMap.put(key, seat);
        setUpdateOption();
    }

    public Map<Integer, UserBaseInfo> getSeatUserMap() {
        return seatUserMap;
    }

    public void setSeatUserMap(Map<Integer, UserBaseInfo> seatUserMap) {
        this.seatUserMap = seatUserMap;
        setUpdateOption();
    }

    public void setSeatUser(int key, UserBaseInfo userBaseInfo){
        this.seatUserMap.put(key, userBaseInfo);
        setUpdateOption();
    }

    public int getAddition() {
        return addition;
    }

    public void setAddition(int addition) {
        if(this.addition != addition) {
            this.addition = addition;
            setUpdateOption();
        }
    }

    public long getDecorationOverTime() {
        return decorationOverTime;
    }

    public void setDecorationOverTime(long decorationOverTime) {
        if(this.decorationOverTime != decorationOverTime) {
            this.decorationOverTime = decorationOverTime;
            setUpdateOption();
        }
    }

    public String getBaseReward() {
        return baseReward;
    }

    public void setBaseReward(String baseReward) {
        if(!Objects.equals(this.baseReward, baseReward)) {
            this.baseReward = baseReward;
            setUpdateOption();
        }
    }

    public long getExpectProfit() {
        return expectProfit;
    }

    public void setExpectProfit(long expectProfit) {
        this.expectProfit = expectProfit;
    }

    public ZsProjectAdditionData getAdditionData() {
        return additionData;
    }

    public void setAdditionData(ZsProjectAdditionData additionData) {
        this.additionData = additionData;
    }
}
